const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatDate = date => {
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()
  return [year, month, day].map(formatNumber).join('-')
}
const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

const formatLen = (number, length) => {
  if (number == 0) {
    return 0
  }
  return number.toFixed(length)
}

const isEmpty = obj =>{
  if (obj === "" || obj === undefined || obj === "undefined" || obj === null) {
    return true
  } else {
    return false
  }
}
module.exports = {
  formatTime: formatTime,
  formatDate: formatDate,
  formatNumber: formatNumber,
  formatLen: formatLen,
  isEmpty:isEmpty,
}